﻿//
// PopWndLayer.h
// ProjectName:MobileManage
//  FuncTion 弹窗
// Created by mr.l on 16/1/12.
//
//

#ifndef __TestPro__PopWndLayer__
#define __TestPro__PopWndLayer__

#include "cocos2d.h"
#include "cocostudio/CocoStudio.h"
#include "ui/CocosGUI.h"
USING_NS_CC;
using namespace cocostudio::timeline;
using namespace ui;

enum
{
    PopWndCloser_TAG,
    PopWndComplete_TAG
};

class PopWndLayer : public Layer
{
public:
    PopWndLayer();
    ~PopWndLayer();
    static PopWndLayer* createScene(std::string pImageName,std::string pBtnName="",bool bShow=true);
    virtual bool init();
    CREATE_FUNC(PopWndLayer);
    void setOutsideView(Node* bg);
protected:
    virtual void TouchEvents(Touch * pTouch, Event * pEvents);
private:
    void initData();
    void Setbackground(std::string pImagName,bool bShow);//设置背景
    void SetColserBtn(std::string pBtnName);//设置关闭按钮
    void BtnCallBack(Ref *pSender , ui::Widget::TouchEventType type);//按钮事件
    void deleteParticle(float dt);
public:
	//Add by Jack 16.04.04
	//设置标题 如果标题写在代码里应该调用这个方法
    void SetTitleWithUTF(std::string title,int fontsize = 28);
	//设置标题 如果标题由服务器传进来 应该调用这个方法
	void SetTitleWithGB(std::string title,int fontsize = 28);
	//设置文本 如果文本由服务器传进来应该调用这个方法
    void SetContentTextWithGB(std::string text,const Color3B&color,int fontsize = 20,bool Shadow=false);
	//设置文本 如果文本写在代码里应该调用这个方法
	void SetContentTextWithUTF(std::string text,const Color3B&color,int fontsize = 20,bool Shadow=false);
	void AddCallBack(EventListenerTouchOneByOne::ccTouchCallback callback);//增加按钮事件

	Text* getContentText(){ return ContentText; }
    void Show(bool bShow);
    void setClickWndOutsideClose(bool bClose=false);
    Node* Loadcsb(std::string csbName);
    Button * AddButton(std::string normalImage,std::string selectedImage,std::string disableImage);//增加按钮
    Button * SetCompleteButton(std::string normalImage,std::string selectedImage,std::string disableImage);//设置按钮
    Button * GetCloseButton(){return pCloseButton;}
    void releaseFromParent();
    Sprite * GetPopWndSize()
    {
        return PopwndBg;
    }
    void PopWndAction();
    //void PopWndEffectseffects(std::string EffectName, bool bShow=false);
private:
    Sprite * PopwndBg;
    Sprite * TouchEventSpt;
    Button * pCloseButton;
    Button * pCustombutton;
    Button * pCombutton;
    EventListenerTouchOneByOne *listener;
    Label * ltfTitle;
    Text * ContentText;
    int AddBtnTag;
    bool m_bIsClickWndOutSideClose;
    bool m_bIsRunAction;
    bool m_bIsRunEffect;
    //ParticleSystemQuad * _emitter;
    static PopWndLayer * popWndLayerSingleton;
    
   Node* m_node;
    //bool m_isShow = false;
};

#endif /* defined(__TestPro__PopWndLayer__) */